<?php
	$cookie = dirname(__FILE__) . DIRECTORY_SEPARATOR . "tmp/cookies.txt";
	 
	 
	//文件不存在则新建一个
	if(!file_exists($cookie)) {
		$handle = fopen($cookie , "w");
		fclose($handle);
	}	
	
	$ua = "Mozilla/5.0 (Windows NT 5.1; rv:6.0.1) Gecko/20100101 Firefox/6.0.1 ";
	
	$img_url = "http://yjcx.chinapost.com.cn/image";


	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $img_url);
	curl_setopt($ch,CURLOPT_COOKIEFILE,$cookie);
	//curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
	curl_setopt($ch, CURLOPT_HEADER, 0);	
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_USERAGENT, $ua);
	curl_setopt($ch,CURLOPT_FOLLOWLOCATION ,1);
	echo $img = curl_exec($ch);
	//file_put_contents('img.jpg',$img);
	curl_close($ch);	
	
	
	
	